﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MegavaniaX.Messaging.Events;

namespace MegavaniaX.Actors.Weapons
{
    public class Buster : WeaponBase
    {
        private Player _player;

        public override string WeaponName
        {
            get { return "buster"; }
        }

        public Buster(Player player)
        {
            _player = player;
        }

        public override void FirePrimary(WeaponModifiers modifiers)
        {
            // make sound
            var soundevt = new PlaySoundEvent(MegavaniaEventType.PlaySound, "sound/Buster");
            _player.DispatchEvent(soundevt);

            // fire bullet
            float posX, posY, velX;
            string actorType = "bullet";
            posY = _player.Top + 8.0f;
            if (_player.IsFacingLeft)
            {
                posX = _player.Left - 2.0f;
                velX = -0.30f;
            }
            else
            {
                posX = _player.Right + 2.0f;
                velX = 0.30f;
            }
            var bulletevt = new SpawnActorEvent(MegavaniaEventType.SpawnActor, actorType, posX, posY, velX, 0, 0, 0);
            _player.DispatchEvent(bulletevt);
        }

        public override void FireSecondary(WeaponModifiers modifiers)
        {            
            // nothing!
        }


    }
}
